#{extends 'main.html'/}
#{set title:'Respond to reviewer requests'/}
<h1> respond to ${project.name} reviewer requests  </h1>
#{set 'crumbs'}
<li><a href="/show/projects">Projects</a></li>
<li><a href="/show/project?id=${project.id}">${project.name}</a></li>
#{/set}
<form onsubmit="return false">
<div>
			#{list items:requests ,as :'request'}
			<div>  <h6> User : ${request.user.name}</h6> </div>
	
			<div>reviewer to Component : ${request.component.name}</div>
			   <option id="${request.id}">For Task Type : ${request.types.name}</option>
		
			 
        <button id="button1_${request.id}" onclick="Accept(${request.id})">Accept</button>
	  <button id="button2_${request.id}" onclick="javascript:Reject(${request.id})">Reject</button>
	  <label id = "message_${request.id}"></label>
	     
			#{/list}	
</div>
</form>

#{if check}
<label>There are no pending requests !</label>
#{/if}

<script type="text/javascript">
function Accept(typeID)
{

	$.post('@{accept()}',
			{requestID:typeID
		},
			function(message)
			{
				$('#button1_'+typeID).hide();
				$('#button2_'+typeID).hide();
				$('#message_'+typeID).html("<font color='Red'>"+message+"</font>");
				
			});
}


</script>
<script type="text/javascript">
function Reject(typeID)
{

	
	
	$.post('@{reject()}',
			{requestID:typeID
		},
			function(message)
			{
				
				$('#button2_'+typeID).hide();
				$('#button1_'+typeID).hide();
				$('#message_'+typeID).html("<font color='Red'>"+message+"</font>");
			});
}


</script>
